home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9188 < prev    next >
Encoding:
Text File  |  1996-08-05  |  8.5 KB  |  263 lines

  1. Path: news.ucdavis.edu!usenet
  2. From: "Harry H. Cheng" <hhcheng@ucdavis.edu>
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: CH Language Environment
  5. Date: Tue, 27 Feb 1996 10:00:13 -0800
  6. Organization: University of California, Davis
  7. Message-ID: <313346AD.645F@ucdavis.edu>
  8. NNTP-Posting-Host: dragon.engr.ucdavis.edu
  9. Mime-Version: 1.0
  10. Content-Type: multipart/mixed; boundary="------------2F946DD86DF8"
  11. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.3 sun4m)
  12.  
  13. This is a multi-part message in MIME format.
  14.  
  15. --------------2F946DD86DF8
  16. Content-Type: text/plain; charset=us-ascii
  17. Content-Transfer-Encoding: 7bit
  18.  
  19. I thought I posted this message on comp.lang.c
  20. yesterday. But, I could not see it today.
  21. In case it falled through the crack. Here is the message again
  22.  
  23. --------------2F946DD86DF8
  24. Content-Type: text/plain; charset=us-ascii
  25. Content-Transfer-Encoding: 7bit
  26. Content-Disposition: inline; filename="l4"
  27.  
  28.  
  29. I would like to announce that the CH language environment
  30. is available to users of SunOS, Solaris, LynxOS.
  31. CH is designed as a superset of C interpreter.
  32. It can be used for Unix shell programming, WWW Common
  33. Gateway Interface, WWW Common Client Interface, ...
  34. The differences between CH and C are highlighted as follows:
  35.  
  36.  
  37. EXTENSIONS TO C (some features are currently debated by 
  38. C Standard Committee ANSI/X3J11 and ISO/SC22/WG14 as new 
  39. features of the next version of C standard called C9x)
  40.  
  41. (1) CH is an interpretive implementation of ANSI C as Unix shell.
  42.     It can be used as login shell. Here are some differences between 
  43.     CH and C shells.
  44.  
  45.           CH shell                           C shell
  46.     _path = "/usr/bin /bin"            set path = (/usr/bin /bin)
  47.     printf("%s\n", getenv("PATH"))
  48.     putenv("PATH=/usr/bin /bin")       setenv PATH "/usr/bin /bin" 
  49.     printf("%s\n", getenv("PATH"))     echo $PATH
  50.     echo $(getenv("PATH"))             echo $PATH
  51.     printf("%s\n", _path)              echo $path
  52.     remenv("PATH")                     unsetenv PATH
  53.     emvar("_path")                     unset path 
  54.     int i = 90                         set i =90
  55.     i = 91                             set i =91
  56.     string hostnam =`hostname`         set hostnam =`hostname`
  57.     alias("rm", "rm -i")               alias rm 'rm -r' 
  58.     unalias("rm")                      unalias rm 
  59.     _histsize = 100                    history = 100
  60.     history                            history 
  61.     ls ~ *                             ls ~ *
  62.     ls > output                        ls > output
  63.     ls $(getenv("PATH"))               ls $PATH
  64.     ls $_path                          ls $path
  65.     $l -agl                            !l -agl
  66.     $3                                 !3 
  67.     $-1                                !-1
  68.     $$                                 !!
  69.     more .chshrc .chlogin .chlogout    more .cshrc .login .logout
  70.     more .rchshrc .chlogin .chlogout   more .cshrc .login .logout
  71.     more .schshrc .chlogin .chlogout   more .cshrc .login .logout
  72.  
  73.     restricted shell                    restricted shell
  74.  
  75.  
  76. There is safe shell in CH for internet computing.
  77. In addition to restrictions imposed by conventional restricted shell,
  78. the following features are disallowed for across-network internet computing
  79. in safe CH shell.
  80.     (a) declaration of pointers.
  81.     (b) built-in functions remove(), rename(), unlink(), open(), and fopen().
  82. The restrictions above are enforced after .schshrc is interpreted.
  83. If CH is invoked with option -S, options -r and -f will be ignored.
  84.  
  85. (2) Complex is a built-in data type 
  86. handled similar to that in Fortran.
  87. For example,
  88.       float f=90;
  89.       complex z=complex(1,2);
  90.       z = 2*f*z*sin(z)*atan(z);
  91.  
  92. (3) String is a first-class object for across-network computing.
  93. For example,
  94.       string s, a[3];
  95.       s = "great string"
  96.       strcpy(a[0], s);
  97.       strcat(s, s);
  98.       printf("s = %s\n", s);
  99.  
  100. (4) Functions can be nested and recursively nested
  101. similar to implementation in GNU gcc.
  102. For example,
  103.       int func1() {
  104.          void func2() {
  105.             int func3() { ...}
  106.          }
  107.          ...
  108.          func2();
  109.       }  
  110.  
  111. (5) Arrays of variable length. They include
  112. deferred-shape arrays, assumed-shape arrays, and pointer
  113. to assumed-shape arrays.
  114. The following example will clarify the concepts of these
  115. various array definitions.
  116.   void funct(int a[:][:], (*b)[:], c[], n, m){
  117.   /* a: assumed-shape array */
  118.   /* b: pointer to array of assumed-shape */
  119.   /* c: incomplete array completed by function call */
  120.     int d[4][5];     /* d: fixed-length array */
  121.     int e[n][m];     /* e: deferred-shape array */
  122.     int (*f)[:];     /* f: pointer to array of assumed-shape */
  123.     extern int g[];  /* g: incomplete array completed by external linkage */
  124.     int h[] = {1,2}; /* h: incomplete array completed by initialization */
  125.     e[1][2] = a[2][3];
  126.   }
  127.   int A[3][4], B[5][6], C[3];
  128.   funct(A, B, C, 10, 20);
  129.   funct(B, A, C, 85, 85);
  130.  
  131. (6) Arrays of adjustable range.
  132. The range of subscript for an index of array can be adjusted.
  133. For example,
  134.   int a[1:10], b[-5:5], c[0:10][1:10], d[10][1:10], e[n:m], f[n1:m1][1:m2];
  135.   extern int a[1:], b[-5:], c[0:][1:10];
  136.   int funct(int a[1:], int b[1:10], int c[1:][3], int d[1:10][0:20]);
  137.   a[10] = a[1]+2; /* OK */
  138.   a[0] = 90;      /* Error: index out of range */
  139.  
  140. (7) Computational array.
  141. An array qualified by type qualifier {array} is
  142. called  computational array.
  143. A computational array is treated as  a first-class object
  144. as in Fortran 90. For example,
  145.        array float a[10][10], b[10][10];
  146.        a += b+inverse(a)*transpose(a)+sin(a);
  147.  
  148. (8) Fortran arrays.
  149. An array qualified by type qualifier {fortran} is
  150. called fortran-style array.
  151. Unlike a C array,
  152. elements of a fortran-style array are stored column-wise.
  153. For example,
  154.   fortran array float A[10][10], B[10][10];
  155.   fortran float a[10][10], b[10][10];
  156.   float *p;   
  157.   p = &a[0][0];
  158.   *(p+1) = 90; /* <==> a[1][0] = 90; not a[0][1] = 90 */
  159.   funct((float [10])&A[5][10]); /* pass column 6 to function funct() */
  160.  
  161. Fortran code can be ported to CH easily.
  162. We have ported over 10,000 lines of LAPACK package to CH.
  163.  
  164.  
  165. (9)Reference for internet computing.
  166. Reference for basic data types char, short, int,
  167. float, double, as well as data types qualified
  168. by signed, unsigned, long, complex, and dual
  169. can be declared.
  170. Functions can be called by reference.
  171. The same syntax in C++ is used in CH.
  172. For example,
  173.   int i;
  174.   int &j = i;
  175.   int A, B;
  176.   void swap(int &n, int &m); /* the same as in C++ */
  177.   swap(A, B);                /* pass by reference as in Fortran */
  178.  
  179. (10) Many high-level toolboxes and function files such as
  180.     plotxy(), plotxyz(), plotxyf(), plotxyzf() for plotting.
  181.  
  182.  
  183.  
  184. MISSING C FEATURES
  185. (1) struct/union/bit-fields.
  186. (2) pointer to functions.
  187. These features will be implemented in CH in the future.
  188.  
  189.  
  190. WHY CH?
  191.  
  192. (1) Like Java, CH can be used for across network
  193. world-wide distributed computing.
  194. It can be used for WWW Common Gateway Interface (CGI), 
  195. WWW Common Client Interface (CCI).
  196. Toolboxes for CGI and CCI are available.
  197. They are easy to use. Examples of World-Wide
  198. Distributed Computing in the CH language environment
  199. can be found on the WWW at the URL address
  200.    http://iel.ucdavis.edu/CH/tutor/wwdc/
  201.  
  202. (2) If you use common set of C and CH, 
  203. your CH code can be compiled in native C compiler.
  204. Your C programs without structure and pointer to functions
  205. can run in the CH language environment
  206. without compilation. 
  207. Normally, CH is 1.xx% to 100% slower than compiled C code, 
  208. depending on applications. But,
  209. if your code takes advantage of high-level features of CH,
  210. such as inverse(A) for computing inverse of matrix A,
  211. CH code can be 
  212. just as fast as your C program.
  213.  
  214.  
  215. (3) It can be used for rapid prototyping of real-time applications.
  216. It can be used to test your device drivers and hardware setup.
  217.  
  218. (4) Like Basic and C shell, CH is interactive.
  219. If you are not sure a C feature, you can verify it
  220. easily under the CH language environment.
  221. If you are a student learning C, 
  222. you may find this interactive feature is handy.
  223. For example,
  224.  
  225.    prompt> hello.c
  226.    Hello, world!
  227.    (execute hello.c program without compilation)
  228.    prompt> int i, *p;
  229.    prompt> p = &i; 
  230.    prompt> *p = 90;
  231.    prompt> printf("i = %d\n", i);
  232.    i = 90
  233.    prompt> int **p2
  234.    prompt> p2 = &p
  235.    prompt> printf("**p2 = %d\n", **p2)
  236.    **p2 = 90
  237.    prompt> ls * > junkfile
  238.    (all file names go to junkfile)
  239.    prompt> i**p
  240.    8100
  241.    prompt> array a[2][3]
  242.    prompt> a = 2
  243.    prompt> a
  244.    5 5 5 
  245.    5 5 5
  246.    prompt> 2*transpose(a)
  247.    10 10 
  248.    10 10 
  249.    10 10 
  250.    prompt>
  251.  
  252.  
  253. CH runs on SunOS, Solaris, MVME167/LynxOS 2.2.1.
  254. It is available free for downloading
  255. on the WWW at the URL address 
  256.    http://iel.ucdavis.edu/CH/
  257.  
  258.  
  259. Harry Cheng
  260.  
  261. --------------2F946DD86DF8--
  262.  
  263.